# Maintainer: Jelle van der Waa <jelle@vdwaa.nl>

_hkgname=extensible-exceptions
pkgname=haskell-${_hkgname}
pkgver=0.1.1.4
pkgrel=36
pkgdesc="extensible exceptions for both new and old versions of GHC"
url="https://hackage.haskell.org/package/extensible-exceptions"
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'sh')
makedepends=('ghc')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('b63bb6b8bc846571db37c23801b711748a10a27a6a6b25035e992013f6705ad9b3ad86e61a7de839c9ac61c26ad3640b9642a8747d6b76a03336834c39e93dca')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
